/*!
 * \file Constraint.cc
 * \brief Définition des méthodes sur les contraintes
 * \author AMMAR Inès (Responsable), CARBONNEL Jessie (Relecture)
 * \version 1.0
 * \date 01 mars 2013
 */

#include "Constraint.h"

#include <iostream>
#include <string>
#include <set>

using namespace std;

Constraint::Constraint(const Preference &p)
{
    semantic = p.getSemantic();
}


set<int> Constraint::getLeft()const{
    return left;
}

set<int> Constraint::getRight()const{
    return right;
}

void Constraint::addInRight(int o){
    right.insert(o);
}

void Constraint::addInLeft(int o){
    left.insert(o);
}

bool Constraint::isInLeft(const int o)const{
	for (std::set<int>::iterator it=left.begin(); it!=left.end(); ++it)
	{
		if (*it == o){
            return true;
        }
	}
    return false;
}

bool Constraint::isInRight(int o)const{

	for (std::set<int>::iterator it=right.begin(); it!=right.end(); ++it)
	{
		if (*it == o){
            return true;
        }
	}
    return false;
}

void Constraint::show()const{
    
    cout<<"{"<<endl;
	cout<<" { ";
	for (std::set<int>::iterator it=left.begin(); it!=left.end(); ++it)
	{
		cout<<*it<<" ";
	}
     
    cout<<"}"<<endl<<" { ";
    
	for (std::set<int>::iterator it=right.begin(); it!=right.end(); ++it)
	{
		cout<<*it<<" ";
	}
    
    cout<<"} "<<endl<<"}"<<endl;
}



void Constraint::deleteOutcomeInRight(int o)
{
	right.erase(o);
}

void Constraint::deleteOutcomeInLeft(int o)
{
	left.erase(o);
}

int Constraint::getSizeRight()const{
	return (int)right.size();
}

int Constraint::getSizeLeft()const{
	return (int)left.size();
}

string Constraint::getSemantic()const{
	return semantic;
}

void Constraint::setSemantic(string s){
	semantic = s;
}
